package com.zbkj.crmeb.task.sync;

import com.utils.DateUtil;
import com.zbkj.crmeb.store.service.OrderTaskService;
import com.zbkj.crmeb.user.model.UserBill;
import com.zbkj.crmeb.user.service.UserBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Configuration //读取配置
@EnableScheduling // 2.开启定时任务
public class BillTokenSyncTask {
    @Autowired
    private UserBillService userBillService;

    @Scheduled(fixedDelay = 1000 * 60L) //1分钟同步一次数据
    public void init(){
        log.info("---syncBillToken task------create order batch item task: Execution Time - {}", DateUtil.nowDateTime());
        try {
            userBillService.syncBillToken();
        }catch (Exception e){
            e.printStackTrace();
            log.error("syncBillToken.task" + " | msg : " + e.getMessage());
        }

    }
}
